#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
    int n;
    while (scanf("%d", &n) != EOF)
    {
        int i = 1;
        int j = 1;
        for (i = 1;i <= n;i++)
        {
            if (i == 1 || i == n)
            {
                for (j = 1;j <= n;j++)
                {
                    printf("* ");
                }
                printf("\n");
            }
            else
            {
                for (j = 1;j <= n;j++)
                {
                    if (j == 1 || j == n)
                    {
                        printf("* ");
                    }
                    else
                    {
                        printf("  ");
                    } 
                }
                printf("\n");
            }
        }
        
    }
    return 0;
}